package com.loong.web.gp4j.encrypt.ui;

import java.awt.Font;

import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

/**
 * UI构建器
 *
 * @author 张成轩
 */
public class UIBuilder {

	private static String[] DEFAULT_FONT = new String[] { "Table.font", "TableHeader.font", "CheckBox.font",
			"Tree.font", "Viewport.font", "ProgressBar.font", "RadioButtonMenuItem.font", "ToolBar.font",
			"ColorChooser.font", "ToggleButton.font", "Panel.font", "TextArea.font", "Menu.font", "TableHeader.font",
			"OptionPane.font", "MenuBar.font", "Button.font", "Label.font", "PasswordField.font", "ScrollPane.font",
			"MenuItem.font", "ToolTip.font", "List.font", "EditorPane.font", "Table.font", "TabbedPane.font",
			"RadioButton.font", "CheckBoxMenuItem.font", "TextPane.font", "PopupMenu.font", "TitledBorder.font",
			"ComboBox.font" };

	/**
	 * 初始化主题样式
	 */
	private static void initTheme() {

		try {
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch (ClassNotFoundException | InstantiationException | IllegalAccessException
				| UnsupportedLookAndFeelException e) {
		}
		for (int i = 0; i < DEFAULT_FONT.length; i++)
			UIManager.put(DEFAULT_FONT[i], new Font("微软雅黑", Font.PLAIN, 14));
	}

	/**
	 * 初始化主窗口
	 */
	private static void initUI() {

		UI ui = new UI();
		ui.setVisible(true);
	}

	/**
	 * 构建
	 */
	public static void build() {

		initTheme();
		initUI();
	}
}
